package com.caxxb.service.impl;

import cn.hutool.crypto.SecureUtil;
import com.caxxb.dao.UserDao;
import com.caxxb.dao.impl.UserDaoImpl;
import com.caxxb.entity.User;
import com.caxxb.service.UserService;
import com.caxxb.util.PageData;

import java.util.List;

public class UserServiceImpl implements UserService {

    private UserDao userDao=new UserDaoImpl();

    @Override
    public List<User> login(String account_number, String password) {
        return userDao.login(account_number, password);
    }

    @Override
    public List<User> getUserById(int id) {
        return userDao.getUserById(id);
    }

    @Override
    public boolean addUser(User user) {
        String md5str = SecureUtil.md5(user.getPassword());
        user.setPassword(md5str);
        return userDao.addUser(user);
    }

    @Override
    public boolean delUser(int user_id) {
        return userDao.delUser(user_id);
    }

    @Override
    public boolean updateUser(int user_id, User user) {
        return userDao.updateUser(user_id,user);
    }

    @Override
    public PageData<User> getUserByPage(String keywords, int pageNo, int pageSize) {
        return userDao.getUserByPage(keywords,pageNo,pageSize);
    }

    @Override
    public List<User> getusers() {
        return userDao.getusers();
    }

    public PageData<User> getNumByPage(String num, int pageNo, int pageSize){
        return userDao.getNumByPage(num, pageNo, pageSize);
    }

    @Override
    public boolean UpdateUserEmail(String email, int id) {
        return userDao.UpdateUserEmail(email,id);
    }

    @Override
    public boolean UpdateUserPwd(String password, int id) {
        return userDao.UpdateUserPwd(password,id);
    }

}
